package com.itheima.mapper;

import com.itheima.annotation.SysLog;
import com.itheima.pojo.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 部门管理
 */
@Mapper
public interface DeptMapper {

    /**
     * 选择列表
     *
     * @return {@link List}<{@link Dept}>
     */
    @Select("select * from dept")
    List<Dept> selectList();

    /**
     * 按id删除
     *
     * @param id id
     */
    @SysLog
    @Delete("delete from dept where id = #{id}")
    void deleteById(Integer id);

    /**
     * 新增
     *
     * @param dept dept
     */
    @SysLog
    @Insert("insert into dept(name, create_time, update_time) " +
            "values (#{name},#{createTime},#{updateTime})")
    void insert(Dept dept);

    /**
     * 按名称选择计数
     *
     * @param name 名称
     * @return {@link Integer}
     */
    @Select("select count(*) from dept where name = #{name}")
    Integer selectCountByName(String name);
}
